<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>LoRa App Server REST API</title>
  <link rel="icon" type="image/png" href="/vendor/swagger/images/favicon-32x32.png" sizes="32x32" />
  <link rel="icon" type="image/png" href="/vendor/swagger/images/favicon-16x16.png" sizes="16x16" />
  <link href="/vendor/swagger/css/typography.css" media="screen" rel="stylesheet" type="text/css"/>
  <link href="/vendor/swagger/css/reset.css" media="screen" rel="stylesheet" type="text/css"/>
  <link href="/vendor/swagger/css/screen.css" media="screen" rel="stylesheet" type="text/css"/>
  <link href="/vendor/swagger/css/reset.css" media="print" rel="stylesheet" type="text/css"/>
  <link href="/vendor/swagger/css/print.css" media="print" rel="stylesheet" type="text/css"/>
  <script src="/vendor/swagger/lib/jquery-1.8.0.min.js" type="text/javascript"></script>
  <script src="/vendor/swagger/lib/jquery.slideto.min.js" type="text/javascript"></script>
  <script src="/vendor/swagger/lib/jquery.wiggle.min.js" type="text/javascript"></script>
  <script src="/vendor/swagger/lib/jquery.ba-bbq.min.js" type="text/javascript"></script>
  <script src="/vendor/swagger/lib/handlebars-4.0.5.js" type="text/javascript"></script>
  <script src="/vendor/swagger/lib/lodash.min.js" type="text/javascript"></script>
  <script src="/vendor/swagger/lib/backbone-min.js" type="text/javascript"></script>
  <script src="/vendor/swagger/swagger-ui.min.js" type="text/javascript"></script>
  <script src="/vendor/swagger/lib/highlight.9.1.0.pack.js" type="text/javascript"></script>
  <script src="/vendor/swagger/lib/highlight.9.1.0.pack_extended.js" type="text/javascript"></script>
  <script src="/vendor/swagger/lib/jsoneditor.min.js" type="text/javascript"></script>
  <script src="/vendor/swagger/lib/marked.js" type="text/javascript"></script>
  <script src="/vendor/swagger/lib/swagger-oauth.js" type="text/javascript"></script>

  <script type="text/javascript">
    $(function () {
      var url = window.location.search.match(/url=([^&]+)/);
      if (url && url.length > 1) {
        url = decodeURIComponent(url[1]);
      } else {
        url = "/swagger/api.swagger.json";
      }

      window.swaggerUi = new SwaggerUi({
        url: url,
        dom_id: "swagger-ui-container",
        supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
        docExpansion: "list",
        jsonEditor: false,
        apisSorter: "alpha",
        defaultModelRendering: 'schema',
        validatorUrl: null,
        onComplete: function(swaggerApi, swaggerUi) {
          addApiKeyAuthorization();
        }
      });

      function addApiKeyAuthorization(){
        var key = encodeURIComponent($('#input_apiKey')[0].value);
        if(key && key.trim() != "") {
            window.swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("Grpc-Metadata-Authorization", 'Bearer ' + key, "header"));
            console.log("added key " + key);
        }
      }
      $('#input_apiKey').change(addApiKeyAuthorization);

      window.swaggerUi.load();
    });
  </script>
</head>

<body class="swagger-section">
  <div id='header'>
    <div class="swagger-ui-wrap">
      <span id="logo">LoRa App Server REST API</span>
      <form id='api_selector'>
        <div class='input'><input placeholder="JWT TOKEN" id="input_apiKey" name="apiKey" type="text"/></div>
      </form>
    </div>
  </div>

  <div id="message-bar" class="swagger-ui-wrap" data-sw-translate>&nbsp;</div>
  <div id="swagger-ui-container" class="swagger-ui-wrap"></div>
</body>
</html>
